package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.data.CustAttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import java.time.LocalDate;

/**
 * 要求完成时间
 */
public class RequiredCompletionTimeAttrHandler extends AbstractAttrHandler<KiteInst, CustAttrData> {

    @Override
    public void def(KiteAttr attr, KiteInst inst, CustAttrData data) {
        LocalDate afterThreeDays = LocalDate.now().plusDays(3);
        int year = afterThreeDays.getYear();
        int month = afterThreeDays.getMonthValue();
        int day = afterThreeDays.getDayOfMonth();
        StringBuilder builder = new StringBuilder();
        builder.append(year).append("-").append(month).append("-").append(day);
        String date = builder.toString();
        if(!KiteStringUtils.isEmpty(date)){
            attr.setValue(date);
        }
    }
}
